package viewPackage;

import java.awt.*;
import javax.swing.JComponent;

@SuppressWarnings("serial")
public class PerspectiveRectangle extends JComponent {

	private Point p1;
	private Point p2;
	private Point p3;
	private Point p4;
		
	public PerspectiveRectangle(Point TL, Point TR, Point BR, Point BL) {
		this.p1 = TL;
		this.p2 = TR;
		this.p3 = BR;
		this.p4 = BL;
	}
	
	public void paintComponent(Graphics g) {
		g.drawLine(p1.x, p1.y, p2.x, p2.y);
		g.drawLine(p2.x, p2.y, p3.x, p3.y);
		g.drawLine(p3.x, p3.y, p4.x, p4.y);
		g.drawLine(p4.x, p4.y, p1.x, p1.y);
	}
	
	public void fillComponent(Graphics g) {
		int[] x = new int[4];
		x[0] = p1.x;
		x[1] = p2.x;
		x[2] = p3.x;
		x[3] = p4.x;
		
		int[] y = new int[4];
		y[0] = p1.y;
		y[1] = p2.y;
		y[2] = p3.y;
		y[3] = p4.y;
		
		g.fillPolygon(x, y, 4);
	}
	
}